//
// Created by Chasing on 2025/8/17.
//

#ifndef MAINCHARTS_H
#define MAINCHARTS_H

#include <QWidget>
#include <QThread>
#include <QChart>
#include <QChartView>
#include <QValueAxis>
#include <QLineSeries>


QT_BEGIN_NAMESPACE
namespace Ui {
    class MainCharts;
}
QT_END_NAMESPACE

class MainCharts : public QWidget
{
    Q_OBJECT
public:
    MainCharts(float * adder = nullptr,uint8_t len = 0);
    ~MainCharts();

public slots:
    void Charts_refsh();
private slots:
    void on_window_width_valueChanged(int arg1);
    void on_data_buff_valueChanged(int arg1);
    void on_cycle_valueChanged(int arg1);
    void on_data_save_clicked();
    void on_clean_form_clicked();
    void on_pause_clicked();
    void on_start_clicked();

private :
    float * data_source; //数据指针
    int32_t count ; // 计数器
    int32_t data_buff; //数据缓存空间
    int32_t window_width;//
    int32_t data_cycle; //数据采集周期

    bool refresh_flag; //刷新标志位

    QValueAxis * m_axisX;
    QValueAxis * m_axisY;
    QLineSeries *m_lineSeries;
    QChart *m_chart;
    Ui::MainCharts *ui;

    QTimer *data_time;
private:
    void set_SliderWidth(int width,int all_width);
    void set_Chasrt_AxisX_Range(int min_x,int max_x);
    void set_Chasrt_AxisY_Range(int min_y,int max_y);
};
#endif //GAMEPAD_RC_CHARTS_H
